<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/denglu.css">
</head>

<body>
    <div class="box">
        <div class="dingbu">
            <div class="dingbu-zuo">
                <a href="" class="dingbu-a"></a>
                <span>账号登录</span>
            </div>
            <div class="dingbu-you">
                <a href="./zuce.html">
                    <span>注册海尔账号</span>
                </a>
                <span class="span">
                    <a href="">
                        梦享
                        <i>+</i>
                        会员首次激活登录
                    </a>
                </span>
            </div>
        </div>
        <div class="datu">
            <div>
                <div class="denglu">
                    <div class="denglu1">登录海尔模块</div>
                    <div class="denglu2">
                        <div class="denglu3">
                            <div class="putong">
                                <a href="">
                                    <a href="" class="a1"></a>
                                    <span>普通登录</span>
                                </a>
                            </div>
                            <div class="shouji">
                                <a href="">
                                    <a href="" class="a1"></a>
                                    <span>
                                        使用手机
                                        <div>动态密码登录</div>
                                    </span>
                                </a>
                            </div>
                            <div class="erweima">
                                <a href=""></a>
                            </div>
                        </div>
                        <div class="dv">
                            <!-- <img src="./img/ren.png" alt=""> -->
                            <input class="ipt" type="text">
                        </div>
                        <div class="dv1">
                            <!-- <img src="./img/ren.png" alt=""> -->
                            <input class="ipt1" type="password">
                            <img src="../img/wangjimima.png" alt="">
                        </div>
                        <div class="tongyi">
                            <input type="checkbox" class="tongyi1" id="checka"></input>
                            <span class="tongyi2">
                                <span class="sp">我同意</span>
                                <a class="sp1">《海尔注册用户服务条款》</a>
                                <a class="sp2">《法律声明及隐私权政策》</a>
                            </span>
                        </div>
                        <div class="tongyi3">
                            <input type="checkbox" class="tongyi1" id="checkb"></input>
                            <span class="tongyi2">
                                <span class="sp">两周内免登录</span>
                            </span>
                        </div>
                        <button class="login-btn">登录</button>
                        <div class="tiao">
                            <a href="">微信</a>&nbsp;&nbsp;
                            <a href="">微博</a>&nbsp;&nbsp;
                            <a href="">网易</a>&nbsp;&nbsp;
                            <a href="">人人网</a>&nbsp;&nbsp;
                            <a href="">开心网</a>
                        </div>
                    </div>
                </div>
                <div class="alert">
                    <span>请填写账号密码</span>
                </div>
            </div>
        </div>
        <div class="dibu">
            <div class="dibu1">
                <div class="dibu-you">
                    <a href="">关于海尔</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                    <a href="">联系我们</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                    <a href="">法律声明</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                    <a href="">帮助中心</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                    <a href="">海尔门店</a>
                </div>
                <div class="dibu-zuo">
                    <div>鲁ICP备09096283 | Copyright ©2000-2020 haier.com ALL Rights Reserved</div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="../node_modules/jquery/dist/jquery.min.js"></script>
<script src="../node_modules/jquery.cookie/jquery.cookie.js"></script>
<script>
    ; (function () {
        let checka = $('#checka')
        let checkb = $('#checkb'),
            $alert = $('.alert'),
            $alertSpan = $('.alert span')

        let baseUrl = 'http://localhost:2468/';
        $('.login-btn').on('click', function () {
            if ($('.ipt').val() && $('.ipt1').val()) {
                if (checka.prop('checked') && checkb.prop('checked')) {
                    $.ajax({
                        url: baseUrl + 'user/login',
                        type: 'post',
                        data: {
                            phoneNum: $('.ipt').val(),
                            loginKey: $('.ipt1').val()
                        },
                        success(res) {
                            getUserInfo(res.data)

                        }
                    })
                } else {
                    alertFun('请阅读登录协议并勾选')
                }
            } else {
                alertFun('请输入用户名和密码')
                setTimeout(() => {
                    $alert.hide()
                }, 1000);
            }

        })

        //获取用户信息
        function getUserInfo(token) {
            $.ajax({
                url: baseUrl + 'user/getInfo',
                type: 'get',
                data: { ...token },
                success(res) {
                    $.cookie('user-info', JSON.stringify(res.data[0]))
                    // <<<<<<< HEAD
                    // window.location.back(-1)
                    // =======
                    history.back()
                    // >>>>>>> 848abbc68974cd4605967de6564f4d45da3a2719
                }
            })
        }

        function alertFun(val) {
            $alertSpan.html(val)
            $alert.toggle()
        }

    }())


</script>

</html>